<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <title>Nota dos Alunos</title>
    </h:head>
    <h:body>
        <div id="MeganFox">
            <h:graphicImage url="imgs/megan.png" height="500" width="284"/>
        </div>
        <div>
            <h:form>
                <table id="Cadastro">
                    <tr>
                        <td>Nome</td>
                        <td><h:inputText id="nome" value="#{alunoBackBean.aluno.nome}" required="true" requiredMessage="Informe o nome do aluno."/></td>
                    </tr>
                    <tr>
                        <td colspan="2"><h:message for="nome" errorClass="erros"/></td>
                    </tr>
                    <tr >
                        <td>Sobrenome:</td>
                        <td ><h:inputText id="sobrenome" value="#{alunoBackBean.aluno.sobrenome}" required="true" requiredMessage="Informe o sobrenome do aluno."/></td>
                    </tr>
                    <tr>
                        <td colspan="2"><h:message for="sobrenome" errorClass="erros"/></td>
                    </tr>
                    <tr >
                        <td>Nota:</td>
                        <td><h:inputText id="nota" value="#{alunoBackBean.aluno.nota}" required="true" requiredMessage="Informe a nota do aluno." /></td>
                    </tr>
                    <tr>
                        <td colspan="2"><h:message for="nota" errorClass="erros"/></td>
                    </tr>
                    <tr>
                        <td colspan="2"><h:commandButton action="#{alunoBackBean.adicionar}" value="Incluir" /></td>
                    </tr>
                </table>
            </h:form>
        </div>

        <h:form>
            <h:dataTable var="aluno" value="#{alunoBackBean.listaAlunos}" styleClass="tabela"
                         rowClasses="linhaImpar, linhaPar" headerClass="headerTabela">
                <h:column>
                    <f:facet name="header">
                        Nome
                    </f:facet>
                    #{aluno.nome}
                </h:column>
                <h:column>
                    <f:facet name="header">
                        Sobrenome
                    </f:facet>
                    #{aluno.sobrenome}
                </h:column>
                <h:column>
                    <f:facet name="header">
                        Nota
                    </f:facet>
                    #{aluno.nota}
                </h:column>
                <h:column>
                    <h:commandLink action="#{alunoBackBean.aumentarNota(aluno)}">
                        <h:graphicImage url="imgs/arrow-up.png" width="25px" height="25px"/>
                    </h:commandLink>
                    <h:commandLink action="#{alunoBackBean.excluirAluno(aluno)}">
                        <h:graphicImage url="imgs/delete.png" width="25px" height="25px"/>
                    </h:commandLink>
                </h:column>
            </h:dataTable>
        </h:form>
    </h:body>
</html>

